package com.charging.common.constant;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

import com.charging.system.domain.KxSystemInfo;
import io.jsonwebtoken.Claims;

/**
 * 通用常量信息
 *
 * @author charging
 */
public class Constants
{
    /**
     * UTF-8 字符集
     */
    public static final String UTF8 = "UTF-8";

    /**
     * GBK 字符集
     */
    public static final String GBK = "GBK";

    /**
     * 系统语言
     */
    public static final Locale DEFAULT_LOCALE = Locale.SIMPLIFIED_CHINESE;

    /**
     * www主域
     */
    public static final String WWW = "www.";

    /**
     * http请求
     */
    public static final String HTTP = "http://";

    /**
     * https请求
     */
    public static final String HTTPS = "https://";

    /**
     * 通用成功标识
     */
    public static final String SUCCESS = "0";

    /**
     * 通用失败标识
     */
    public static final String FAIL = "1";

    /**
     * 登录成功
     */
    public static final String LOGIN_SUCCESS = "Success";

    /**
     * 注销
     */
    public static final String LOGOUT = "Logout";

    /**
     * 注册
     */
    public static final String REGISTER = "Register";

    /**
     * 登录失败
     */
    public static final String LOGIN_FAIL = "Error";

    /**
     * 所有权限标识
     */
    public static final String ALL_PERMISSION = "*:*:*";

    /**
     * 管理员角色权限标识
     */
    public static final String SUPER_ADMIN = "admin";

    /**
     * 角色权限分隔符
     */
    public static final String ROLE_DELIMETER = ",";

    /**
     * 权限标识分隔符
     */
    public static final String PERMISSION_DELIMETER = ",";

    /**
     * 验证码有效期（分钟）
     */
    public static final Integer CAPTCHA_EXPIRATION = 2;

    /**
     * 令牌
     */
    public static final String TOKEN = "token";

    /**
     * 令牌前缀
     */
    public static final String TOKEN_PREFIX = "Bearer ";

    /**
     * 令牌前缀
     */
    public static final String LOGIN_USER_KEY = "login_user_key";

    /**
     * 用户ID
     */
    public static final String JWT_USERID = "userid";

    /**
     * 用户名称
     */
    public static final String JWT_USERNAME = Claims.SUBJECT;

    /**
     * 用户头像
     */
    public static final String JWT_AVATAR = "avatar";

    /**
     * 创建时间
     */
    public static final String JWT_CREATED = "created";

    /**
     * 用户权限
     */
    public static final String JWT_AUTHORITIES = "authorities";

    /**
     * 资源映射路径 前缀
     */
    public static final String RESOURCE_PREFIX = "/profile";

    /**
     * RMI 远程方法调用
     */
    public static final String LOOKUP_RMI = "rmi:";

    /**
     * LDAP 远程方法调用
     */
    public static final String LOOKUP_LDAP = "ldap:";

    /**
     * LDAPS 远程方法调用
     */
    public static final String LOOKUP_LDAPS = "ldaps:";

    /**
     * 自动识别json对象白名单配置（仅允许解析的包名，范围越小越安全）
     */
    public static final String[] JSON_WHITELIST_STR = { "org.springframework", "com.charging" };

    /**
     * 定时任务白名单配置（仅允许访问的包名，如其他需要可以自行添加）
     */
    public static final String[] JOB_WHITELIST_STR = { "com.charging.quartz.task" };

    /**
     * 定时任务违规的字符
     */
    public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
            "org.springframework", "org.apache", "com.charging.common.utils.file", "com.charging.common.config", "com.charging.generator" };

    /*
    =====================================================================================================================
     */

    /**
     * 系统参数
     */
    public static KxSystemInfo kxSystemInfo = new KxSystemInfo();

    public static final String REDIS_KEY_WE_PUBLIC_ACCESS_TOKEN = "redis_key_we_public_access_token";

    public static final String REDIS_KEY_WE_PUBLIC_TICKET= "redis_key_we_public_ticket";

    public static final String THIRD_PARTY_CERT_PASSWORD = "third_user!!!***";

    public static final String AUTH_KEY = "e101cddaefc26cfdaf368fd5c98ad76f";

    public static final String PAY_SIGN = "yx";
    public static final int USER_TOTAL_CHARGING = 3;

    // 科航设备请求url地址
    public static final String KEHANG_EQUIP_URL = "http://api.zzyxiot.cn/pile/two/charging";
    // 交易类型
    public static class TranType{
        public static final int NOKNOW                      =0;//系统
        public static final int WEIXIN                      =1;//微信
        public static final int ALIPALY                     =2;//支付宝
    }
    // 交易状态
    public static class TranStatus{
        public static final int YES                         = 2;//交易结束
        public static final int IN                          = 1;//处理中
        public static final int NO                          = 0;//开始交易
    }
    // 充电状态
    public static class ChargingStatus{
        public static final int STARTCHARGING               = 0;//开始充电
        public static final int INTCHARGING                 = 1;//充电中
        public static final int ENDCHARGING                 = 2;//结束充电
    }
    // 插座打开关闭状态
    public static class SetChannelState {
        public static final String open ="1";// 打开插座
        public static final String close = "0";// 关闭插座
    }
    public static class YesOrNo{
        public static  final int  YES                       = 1;// 后付款
        public static  final int  NO                        = 0;// 先付款
    }
    // 充电结束类型
    public static class EndType{
        public static final int InitChannel =0; // 初始状态
        public static final int OpenChannelError =1; // 打开通道失败
        public static final int CloseChannel =2; // 主动关闭插座
        public static final int MaxChargingTime =3; // 达到最大充电时长
        public static final int PlanChargingTime = 4; // 达到计划时长
        public static final int NoLoadCurrent = 5; // 充电桩空载（插座未插紧） 1
        public static final int FullStop = 6; // 充满自停 2
        public static final int Overload = 7;// 过载（超过充电功率） 3
        public static final int OverByCharging = 8; //充电桩停止充电 0
        public static final int BalanceNotEnough = 9; //账户余额不足
        public static final int SystemCloseChannel = 10; //平台关闭插座
        public static final int StartButNoCharge = 11; //开始充电未连接充电器
        public static final int GetMaxChargingTime = 12; //达到最大充电时长
    }
    // 结束类型对应描述
    public static final Map<Integer, String> EndTypeMap = new HashMap<Integer, String>();
    static {
        EndTypeMap.put(EndType.OpenChannelError,"打开通道失败");
        EndTypeMap.put(EndType.CloseChannel,"主动关闭插座");
        EndTypeMap.put(EndType.MaxChargingTime,"达到最大充电时长");
        EndTypeMap.put(EndType.PlanChargingTime,"达到计划时长");
//        EndTypeMap.put(EndType.NoLoadCurrent,"插座未插紧");
        EndTypeMap.put(EndType.NoLoadCurrent,"手动拔掉插座/充电器停止工作");
        EndTypeMap.put(EndType.FullStop,"充满自停");
        EndTypeMap.put(EndType.Overload,"超过充电功率");
        EndTypeMap.put(EndType.OverByCharging,"充电桩停止充电");
        EndTypeMap.put(EndType.BalanceNotEnough,"账户余额不足");
        EndTypeMap.put(EndType.SystemCloseChannel,"平台关闭插座");
        EndTypeMap.put(EndType.StartButNoCharge,"开始充电未连接充电器");
        EndTypeMap.put(EndType.GetMaxChargingTime,"达到最大充电时长");
    }
}
